package com.netbao.sys.vomapper;

import com.netbao.sys.model.Role;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface RoleResVoMapper {
    @Insert("INSERT INTO sys_role_res(role_id,res_id) SELECT #{roleid},id FROM sys_resources WHERE id IN(${resids})")
    void insert(Long roleid, String resids);
    @Delete("delete from sys_role_res where role_id=#{roleid}")
    void delete(Long roleid);
    @Select("SELECT #{userid} userid,r.id,cname,remark,IF(ur.user_id IS NULL,FALSE,TRUE) isdel FROM sys_role r LEFT JOIN sys_user_role ur " +
            "ON(r.id=ur.role_id AND user_id=#{userid})")
    List<Role> getRole(Long userid);

}
